class: center, middle, inverse, title-slide # Rmarkdown ## The first trick ### Fabio CRUZ ### Université de Lorraine ### 2021/02/01 (updated: 2021-01-29) --- # We are assuming... You have know how works: - Github - RStudio And you are eager to see the magic happen. So let's start... ```{=html} <div class="countdown" id="timer_60147342" style="right:0;bottom:0;left:0;margin:5%;padding:15px;font-size:6em;" data-warnwhen="0"> <code class="countdown-time"><span class="countdown-digits minutes">01</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">30</span></code> </div> ``` --- # Learning outcomes - You will produce your first reproducible document and put it online - You will have a basic understanding of the main functions of Rmarkdown --- # Agenda of this sprint ### 1. Understanding the Rmarkdown ### 2. Connecting with github to publish your work! --- class: center # What is Rmarkdown? <img src="data:image/png;base64,#https://bookdown.org/yihui/rmarkdown/images/hex-rmarkdown.png" width="40%" style="display: block; margin: auto;" /> --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd.png) background-position: 50% 5px background-size: 70% class: middle, bottom **here**, you can see a typical single R Markdown file. <br> This one is for a lab for visualizing data from the Museum of Modern Art.<br> Let's quickly walk through some of the key parts of this file. --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd0.png) background-position: 50% 5px background-size: 70% class: middle, bottom It starts with **metadata**, written in `YAML`, which is a list of keys on the left and their values on the right. --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd1.png) background-position: 50% 5px background-size: 70% class: middle, bottom The first key you see is the **TITLE**, which is `Lab 02: MoMA Museum Tour`. --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd2.png) background-position: 50% 5px background-size: 70% class: middle, bottom The last YAML section is all about **output**. Here the output is an **`html_document`**. --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd3.png) background-position: 50% 5px background-size: 70% class: middle, bottom Beneath that, we can add options to our **`html_document`** - for example, a table of contents, with the key **TOC** set to **TRUE**. --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd4.png) background-position: 50% 5px background-size: 70% class: middle, bottom So that's the metadata, but the real meat in your R Markdown file is text written in **markdown**... --- Markdown --- background-image: url(data:image/png;base64,#img/screenshots/Single-rmd5.png) background-position: 50% 5px background-size: 70% class: middle, bottom and your code, written in R. So these 3 things: (1) **Metadata**, (2) *Text*, and (3) **Code** make up an *R Markdown* document. --- class: top center <video width="1530" height="610" controls> <source src="img/single-doc-knit.mp4" type="video/mp4"> </video> The real magic happens, when you click on the `**Knit icon**`, and see your file turned into HTML. --- background-image: url(data:image/png;base64,#img/screenshots/Single-knit1.png) background-position: 50% 5px background-size: 70% class: middle, bottom Here is what we knit. -- <img src="img/screenshots/Single-knit2.png" style=" position: absolute; width: 91%; top: -53px; right: 5px; "> Using the **`THEME:`** key in our YAML, we changed our font and colors. -- <img src="img/screenshots/Single-knit3.png" style=" position: absolute; width: 97%; top: -45px; right: -51px; "> -- <img src="img/screenshots/Single-knit4.png" style=" position: absolute; width: 73%; bottom: 10px; right: 80px; "> But **this is still local and stuck on my computer/ Rstudio Cloud**. --- name: clouds class: center, middle background-image: url(data:image/png;base64,#img/Clouds.jpg) background-size: cover class: center, middle # How do we start .emphasis[sharing]? # We are going to publish this on the web ! --- # Commit your files on github 1. Go to the `Environment Panel`and got to `Git` tab. 2. Select each element that appears to be changed. - You can use `Ctrl / Cmd + A` to select of of them, and press `Enter` 3. Click on Commit 4. Click on `Push`